package com.xiaolin.security.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.configuration.EnableGlobalAuthentication;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName WebSecurityConfig
 * @Description Spring security web 配置
 * @Detail 自定义用户的一种方式
 * @Author MyPC
 * @Date 2020/10/8
 * @Version 1.0
 */
@EnableGlobalMethodSecurity(prePostEnabled = true)  // 注解来控制权限时需要开启该注解
@EnableWebSecurity
public class WebSecurityConfig implements WebMvcConfigurer{
//    @Bean
//    public UserDetailsService userDetailsService(){
//        InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
//        manager.createUser(User.withDefaultPasswordEncoder().username("user").password("1234567").roles("admin").build());
//        return manager;
//    }
}
